Skip to content

gh-145241: specialize SyntaxError for single trailing-comma with item#145282

Merged
pablogsal merged 5 commits intopython:mainfrom
pablogsal:gh-145241-with-trailing-comma-news
Feb 28, 2026
Merged

gh-145241: specialize SyntaxError for single trailing-comma with item#145282
pablogsal merged 5 commits intopython:mainfrom
pablogsal:gh-145241-with-trailing-comma-news

Conversation

@pablogsal
Copy link
Member

@pablogsal pablogsal commented Feb 26, 2026

@pablogsal pablogsal force-pushed the gh-145241-with-trailing-comma-news branch from 3433bc5 to 4994e57 Compare February 26, 2026 21:46
Copy link
Member

@johnslavik johnslavik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I've researched this a bit more, and I think we can make this even better :-)
Sorry for the resulting back-and-forth and not enough research in the issue.

The syntax error happens every time the last with item (could be one or could be multiple overall) has a bare trailing comma and items aren't parenthesized.

We'd want to add cases with multiple items as well and adapt the error message accordingly. I've added suggestions ready for you to apply. Please feel free to pick better phrasing though.

PS Also suggested using RAISE_SYNTAX_ERROR_KNOWN_LOCATION so that the caret ^ points at the faulty trailing comma (right now the caret points at the colon).

pablogsal and others added 3 commits February 28, 2026 01:46
Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
@pablogsal pablogsal enabled auto-merge (squash) February 28, 2026 01:47
…e-145241.hL2k9Q.rst

Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
@pablogsal pablogsal merged commit 09e8c38 into python:main Feb 28, 2026
47 checks passed
@pablogsal pablogsal deleted the gh-145241-with-trailing-comma-news branch February 28, 2026 02:24
@johnslavik johnslavik added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Feb 28, 2026
@miss-islington-app
Copy link

Thanks @pablogsal for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@miss-islington-app
Copy link

Thanks @pablogsal for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Sorry, @pablogsal, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 09e8c382312b145b710dca7072ff2e13fe8c09ab 3.13

@miss-islington-app
Copy link

Sorry, @pablogsal, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 09e8c382312b145b710dca7072ff2e13fe8c09ab 3.14

@johnslavik
Copy link
Member

Uhh no, not worth it maybe.

@johnslavik johnslavik removed needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Feb 28, 2026
@johnslavik
Copy link
Member

johnslavik commented Feb 28, 2026

I've requested backports because #142236 (comment), but I'm giving up on that in this case. Too much effort.

bkap123 pushed a commit to bkap123/cpython that referenced this pull request Feb 28, 2026
…h item (python#145282)

Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants